package org.netty.framework.core.annotation;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;

/**
 * 手动注册bean注入到spring容器中
 * 
 * @author chenfanglin
 * @date 2018年9月26日下午7:47:27
 */
public class NettyServerRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware {

	private ApplicationContext applicationContext;

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setResourceLoader(ResourceLoader resourceLoader) {
		this.applicationContext = (ApplicationContext) resourceLoader;
	}

	@Override
	public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
		new AnnotationScanner().scan(applicationContext, importingClassMetadata, registry);
	}

}
